package com.xintouyun.medicine.service.impl;

import java.util.List;

import com.xintoucloud.jdbcutil.JdbcUtil;
import com.xintouyun.medicine.dao.SupermanDao;
import com.xintouyun.medicine.entity.Superman;
import com.xintouyun.medicine.model.DataGrid;
import com.xintouyun.medicine.service.SupermanService;


public class SupermanServiceImpl implements SupermanService{
	private SupermanDao supermandao=new SupermanDao();
	@Override
	public DataGrid<Superman> list(int page, int rows) {
		try {
			DataGrid <Superman> data=new DataGrid<>();
			int count=supermandao.count("select count(*) from m_superman", null);
			List<Superman> superman=supermandao.list("select upwd,aname,state from m_superman limit ?,?",(page-1)*rows,rows);
			data.setTotal(count);
			data.setRows(superman);
			return data;
		}finally {
			JdbcUtil.closeConnection();
		}
	}
	@Override
	public Superman login(String username, String password) {
		try {
			Superman superman=supermandao.get("select * from m_superman where name=? and upwd=?", username,password);
			return superman;
		}finally {
			JdbcUtil.closeConnection();
		}
	}

}
